//
//  MCLiveIntroduceView.m
//  DouYuDemo
//
//  Created by 覃木春 on 2018/9/27.
//  Copyright © 2018年 覃木春. All rights reserved.
//

#import "MCLiveIntroduceView.h"

@interface MCLiveIntroduceView ()



@end

@implementation MCLiveIntroduceView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI{
    self.backgroundColor = RGBA(255, 255, 255, 1);
    [self addSubview:self.noticeLB];
    [self addSubview:self.introduceLB];
    [self addSubview:self.headImage];
    [self addSubview:self.liveNameLB];
    [self addSubview:self.viewingLB];
    
    [self.noticeLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.mas_equalTo(self);
        make.height.mas_equalTo(MCAutoLayout(30));
    }];
    
    [self.introduceLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self).offset(MCAutoLayout(10));
        make.right.mas_equalTo(self).offset(MCAutoLayout(-10));
        make.top.mas_equalTo(self.noticeLB.mas_bottom).offset(MCAutoLayout(2));
        make.height.mas_equalTo(MCAutoLayout(50));
    }];
    
    [self.headImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self).offset(MCAutoLayout(10));
        make.width.height.mas_equalTo(MCAutoLayout(50));
        make.top.mas_equalTo(self.introduceLB.mas_bottom);
    }];
    
    [self.liveNameLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.headImage.mas_right).offset(MCAutoLayout(10));
        make.right.mas_equalTo(self).offset(MCAutoLayout(-10));
        make.top.mas_equalTo(self.headImage).offset(MCAutoLayout(3));
        make.height.mas_equalTo(MCAutoLayout(27));
    }];
    
    [self.viewingLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.headImage.mas_right).offset(MCAutoLayout(10));
        make.right.mas_equalTo(self).offset(MCAutoLayout(-10));
        make.top.mas_equalTo(self.liveNameLB.mas_bottom);
        make.height.mas_equalTo(MCAutoLayout(15));
    }];
}


#pragma mark =================== get ===================

- (UILabel *)noticeLB{
    if (!_noticeLB) {
        _noticeLB = [UILabel new];
        _noticeLB.textColor = RGBA(67, 67, 67, 1);
        _noticeLB.backgroundColor = RGBA(242, 242, 242, 1);
        _noticeLB.font = MCFont(13);
        _noticeLB.textAlignment = NSTextAlignmentCenter;
        _noticeLB.text = @"直播公告xxxxxxx";
    }
    return _noticeLB;
}

- (UILabel *)introduceLB{
    if (!_introduceLB) {
        _introduceLB = [UILabel new];
        _introduceLB.textColor = RGBA(67, 67, 67, 1);
        _introduceLB.backgroundColor = [UIColor clearColor];
        _introduceLB.textAlignment = NSTextAlignmentLeft;
        _introduceLB.font = MCFont(13);
        _introduceLB.text = @"斗牌杯第一届世界级b扑克竞赛正式开始，大家请关注斗牌TV了解，不容错过~";
        _introduceLB.numberOfLines = 2;
    }
    return _introduceLB;
}

- (UILabel *)liveNameLB{
    if (!_liveNameLB) {
        _liveNameLB = [UILabel new];
        _liveNameLB.textColor = RGBA(51, 51, 51, 1);
        _liveNameLB.backgroundColor = [UIColor clearColor];
        _liveNameLB.textAlignment = NSTextAlignmentLeft;
        _liveNameLB.font = MCBoldFont(16);
        _liveNameLB.text = @"斗牌TV";
    }
    return _liveNameLB;
}

- (UIImageView *)headImage{
    if (!_headImage) {
        _headImage = [[UIImageView alloc] init];
        _headImage.image = [UIImage imageNamed:@"head_img_64"];
        _headImage.layer.masksToBounds = YES;
        _headImage.contentMode = UIViewContentModeScaleAspectFill;
        _headImage.clipsToBounds = YES;
        _headImage.layer.borderWidth = MCAutoLayout(1);
        _headImage.layer.cornerRadius = MCAutoLayout(25);
        _headImage.layer.borderColor = RGBA(167, 167, 167, 1).CGColor;
    }
    return _headImage;
}

- (YYLabel *)viewingLB{
    if (!_viewingLB) {
        _viewingLB = [YYLabel new];
        _viewingLB.numberOfLines = 0;
        _viewingLB.font = MCFont(12);
        _viewingLB.lineBreakMode = NSLineBreakByCharWrapping;
        _viewingLB.textColor = RGBA(167, 167, 167, 1);
        NSString *showMessage = @"直播中 3451人在线";
        NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:showMessage];
        [text setAttributes:@{NSForegroundColorAttributeName:RGBA(167, 167, 167, 1),NSFontAttributeName:MCFont(12)} range:NSMakeRange(0, showMessage.length)];
        [_viewingLB setAttributedText:text];
    }
    return _viewingLB;
}

@end
